package EA.testproblems;
import EA.*;
import java.util.Hashtable;

/** The purpose of this class is to model the concept of a dynamic 
    numerical problem. 
    It is supposed to be subclassed into the problems your EA attempt to 
    attack.
    It contains the relevant informations about a numerical problems such as
    objective function, known maximas and minimas, etc. 
*/
public class DynamicNumericalProblem extends NumericalProblem
{
  /** The current iteration. Increased by one when updateProblem() is 
      invoked. */
  public int curiteration;
  /** The number of iterations between each change of the problem. */
  public int staticperiod;

  /** The number of iterations since the problem was updated last. */
  public int curiteration_cnt;

  /** The number of periods so far. */
  public int staticperiod_cnt;

  public DynamicNumericalProblem()
    {
      super();
      curiteration = 0;
    }

  /** Update the dynamic problem. You are responsible for calling this 
	method from your main loop. <br>
	<b>Note:</b> This method must be overridden in your subclass.
	@return True if the problem was updated.
    */
  public boolean updateProblem()
    {
      curiteration++;
      if (curiteration%staticperiod==0) {
	    
	return true;
      }
      return false;
    }

  /** Reset the dynamic problem. This will set curiteration to zero and 
      call DNP_resetProblem_inner().  You should call this every time
      you restart your algorithm. */
  public final void NumericalProblem_resetProblem_inner()
    {
      curiteration = 0;
      DNP_resetProblem_inner();
    }

  /** Override this in your subclass with your resetting code. */
  public void DNP_resetProblem_inner()
    {
    }

}
